package com.seecoder.BlueWhale.controller;

import com.seecoder.BlueWhale.service.CouponGroupService;
import com.seecoder.BlueWhale.service.CouponService;
import com.seecoder.BlueWhale.vo.CouponDisplayParams;
import com.seecoder.BlueWhale.vo.CouponVO;
import com.seecoder.BlueWhale.vo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/coupon")
@Slf4j
public class CouponController {

    @Autowired
    CouponService couponService;

    @Autowired
    CouponGroupService couponGroupService;

    @PostMapping("/get_all_coupons")
    public ResultVO<List<CouponVO>> getAllCoupons(@RequestBody CouponDisplayParams couponDisplayParams) {
        log.info("get all coupons begin");
        ResultVO<List<CouponVO>> ans = ResultVO.buildSuccess(
                couponService.getAllCoupons(couponDisplayParams.getStoreId(), couponDisplayParams.getPrice(), couponDisplayParams.getChosenTypes()));
        log.info("get all coupons success");
        return ans;
    }
}
